//
//  ImagePicCollectionViewCell.m
//  BTRIP
//
//  Created by johnbk on 15/11/21.
//  Copyright © 2015年 johnbk. All rights reserved.
//

#import "ImagePicCollectionViewCell.h"
#import <SDWebImageManager.h>
#import <UIImageView+WebCache.h>
@implementation ImagePicCollectionViewCell

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(void)dealloc{
	[_imageString release];
	[_imgView release];
	[super dealloc];
}
-(instancetype)initWithFrame:(CGRect)frame{
	self = [super initWithFrame:frame];
	if (self) {
		[self createView];
	}
	return self;
}
-(void)createView{
	self.imgView = [[UIImageView alloc]init];
	[self.contentView addSubview:self.imgView];
	[self.imgView release];
	self.imgView.userInteractionEnabled = YES;
	UIPinchGestureRecognizer *pinchGesture = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(pinchGestureAction:)];
	[self.imgView addGestureRecognizer:pinchGesture];
	[pinchGesture release];
	
}
- (void)pinchGestureAction: (UIPinchGestureRecognizer *)gestureRecognizer{
	self.imgView.transform = CGAffineTransformScale(self.imgView.transform, gestureRecognizer.scale, gestureRecognizer.scale);
	gestureRecognizer.scale = 1;
}

-(void)layoutSubviews{
	[super layoutSubviews];
	self.imgView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.width * 0.618);
	self.imgView.center = CGPointMake(self.frame.size.width / 2, self.frame.size.height / 2);
}
-(void)setImageString:(NSString *)imageString{
	if (_imageString != imageString) {
		[_imageString release];
		_imageString = [imageString retain];
		[self.imgView sd_setImageWithURL:[NSURL URLWithString:imageString] placeholderImage:[UIImage imageNamed:@"background"]];
		
	}
}
@end
